package com.fcscs.cservice.service;

import java.util.List;

import org.springframework.stereotype.Service;

import com.fcscs.cservice.common.CServiceCommonEnums.ModuleEnum;
import com.fcscs.cservice.common.CServiceCommonEnums.UpdateVerLevelEnum;
import com.fcscs.cservice.common.CServiceCommonEnums.VersionEntityTypeEnum;
import com.fcscs.cservice.common.CServiceCommonEnums.VersionTypeEnum;
import com.fcscs.cservice.domain.VersionUpdates;
import com.fcscs.cservice.domain.Versions;
import com.fcscs.cservice.domain.model.EntityVersionView;
import com.fcscs.cservice.domain.model.VersionView;

@Service
public interface ECMSVersionManager {

	//----------For load and save template dialog--------------
	List<Versions> getVersions(long orgId, long propId, ModuleEnum module, VersionTypeEnum versionType, VersionEntityTypeEnum entityType);

	Versions createVersion(long orgId, long propId, Versions ver);
	
	boolean deleteVersion(Versions ver);
	
	boolean deleteVersionUpdates(VersionUpdates vu);
	
	boolean permDeleteVersion(Versions ver);
	
	boolean permDeleteVersionUpdates(VersionUpdates vu);
	
	boolean isVersionTaken(long orgId, long propId, ModuleEnum module, VersionTypeEnum versionType, VersionEntityTypeEnum entityType, String name, Long id);
	
	Versions saveToTemplate(long orgId, long propId, Versions fromVer, Versions toVer);
	
	Versions copyFromTemplate(long orgId, long propId, Versions fromVer, Versions toVer);
	
	//----------For scheduled job--------------
	List<Versions> getExpiredVersionList(long orgId, long propId);

	boolean expireCurrent(long orgId, long propId, Versions oldScheduled, Versions oldCurrent);

	//----------For web service api--------------
	List<VersionView> getVersionViewList(long orgId, long propId, ModuleEnum module, List<VersionView> verList);

	List<EntityVersionView> getEntityVersionViewList(long orgId, long propId, ModuleEnum module);

	//---------For operations need updating version values (e.g., CUD, update relationships)--------------
	void updateVersionValues(long orgId, long propId, ModuleEnum module, VersionEntityTypeEnum entityType, Long entityId, UpdateVerLevelEnum level);
	
	Versions getCurrentVersion(long orgId, long propId, ModuleEnum module);

	Versions getCurrentVersion(long orgId, long propId, ModuleEnum module, boolean autoCreate);
	
	Versions getScheduledVersion(long orgId, long propId, ModuleEnum module);
	
	Versions getScheduledVersion(long orgId, long propId, ModuleEnum module, boolean autoCreate);

	Versions getVersion(long orgId, long propId, ModuleEnum module, VersionTypeEnum versionType, String name);

	List<VersionUpdates> getVersionUpdates(long orgId, long propId, ModuleEnum module, VersionEntityTypeEnum entityType);
}
